//
//  StwxCommentCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/10/23.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "StwxCommentCell.h"

@interface StwxCommentCell()

/// viewModle
@property (nonatomic, readwrite, strong) StwxCommentItemViewModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* nameLabel;
@property (weak, nonatomic) IBOutlet UILabel* dateLabel;
@property (weak, nonatomic) IBOutlet UILabel* contentLabel;
@property (weak, nonatomic) IBOutlet UIImageView* avatarImgView;

@end

@implementation StwxCommentCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(StwxCommentItemViewModel *)viewModel
{
    self.viewModel = viewModel;
    
    self.nameLabel.text = self.viewModel.name;
    self.dateLabel.text = self.viewModel.date;
    self.contentLabel.text = self.viewModel.content;
    
    [self.avatarImgView yy_setImageWithURL:[NSURL URLWithString:self.viewModel.imgurl] placeholder:MHImageNamed(@"placeholderLogo")];
    [[[[self rac_signalForSelector:@selector(layoutSubviews)] takeUntil:[self rac_prepareForReuseSignal]] delay:0.1f] subscribeNext:^(id x)
    {
        self.avatarImgView.layer.cornerRadius = self.avatarImgView.frame.size.height/2.0f;
        self.avatarImgView.layer.masksToBounds = YES;
    }];
}

@end
